<?php
declare (strict_types=1);

namespace app\api\controller;

use app\api\model\User;
use think\Request;
use think\facade\Event;


class UserController
{
    public function list()
    {
        $h = 2;
        $userListHour = User::inHour($h);
//        var_dump(User::getLastSql());
        $m = 30;
        $userListMinutes = User::inMinutes($m);

        $today = User::inTime('today');
        var_dump($today);
//        var_dump(User::getLastSql());
    }

    //实现事件监听
    public function UserLogin()
    {
        $user = ['id' => 1, 'name' => 2];
        //这个是事件监听
        event('UserLogin', $user);
        //Event::trigger('UserInsert', new \app\api\listener\UserInsert($user));
//        event('app\api\listener\UserInsert',['msg' => '好', 'code' => '100']);
        event('UserInsert', ['msg' => '好', 'code' => '100']);
    }

}
